//
//  startupLayer.m
//  pipi
//
//  Created by zhao ys on 5/14/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "startupLayer.h"
#import "playLayer.h"
#import "avatarLayer.h"
#import "scoreLayer.h"
#import "SoundManager.h"

@implementation startupLayer
+(CCScene *) scene
{
	// 'scene' is an autorelease object.
	CCScene *scene = [CCScene node];
	
	// 'layer' is an autorelease object.
	startupLayer *layer = [startupLayer node];
	
	// add layer as a child to scene
	[scene addChild: layer];
	
	// return the scene
	return scene;
}

// on "init" you need to initialize your instance
-(id) init
{
	// always call "super" init
	// Apple recommends to re-assign "self" with the "super" return value
	if( (self=[super init])) {
		// ask director the the window size
		//CGSize size = [[CCDirector sharedDirector] winSize];
		
		
		CCMenuItem * play = [CCMenuItemFont itemFromString:@"[Play]" target:self selector:@selector(OnPlay:)];
		CCMenuItem * help = [CCMenuItemFont itemFromString:@"[Help]" target:self selector:@selector(OnHelp:)];
		CCMenuItem * avatar = [CCMenuItemFont itemFromString:@"[Avatar]" target:self selector:@selector(OnAvatar:)];
		CCMenuItem * score = [CCMenuItemFont itemFromString:@"[Score]" target:self selector:@selector(OnScore:)];
		CCMenuItem * setting = [CCMenuItemFont itemFromString:@"[Setting]" target:self selector:@selector(OnSetting:)];
		CCMenuItem * more_game = [CCMenuItemFont itemFromString:@"[More Game]" target:self selector:@selector(OnMoreGame:)];
		
		
		//CGSize startSize = start.contentSize;
		//start.position = ccp(size.width - startSize.width / 2, size.height - startSize.height / 2);
		CCMenu * menu = [CCMenu menuWithItems:play, help, avatar, score, setting, more_game, nil];
		[menu alignItemsVertically];
		//menu.position = ccp(size.width - menu.contentSize.width / 2, menu.contentSize.height / 2);
		[self addChild:menu];
	}
	return self;
}

-(void) OnPlay:(id)sender {
	[[CCDirector sharedDirector] replaceScene:[PlayLayer scene]];
}

-(void) OnHelp:(id)sender {

}

-(void) OnAvatar:(id)sender {
	[[CCDirector sharedDirector] replaceScene:[avatarLayer node]];
}

-(void) OnScore:(id)sender {
	[[CCDirector sharedDirector] replaceScene:[scoreLayer sceneWithScore:-1]];
}


-(void) OnSetting:(id)sender {

}

-(void) OnMoreGame:(id)sender {

}

@end
